package trading_strategy.orders;

import trading_strategy.instruments.ListedInstrument;

/**
 * Created by IntelliJ IDEA.
 * User: gderoujoux
 * Date: 6 mai 2010
 * Time: 11:13:14
 * To change this template use File | Settings | File Templates.
 */
public abstract class Order {
    int qty;
    ListedInstrument instrument;
    String marketId;
    int internalId;
    String comment;
    boolean cancelRequested = false;
    long creationTimestamp;
    long matchingTimestamp;
    private IOrderAutomaton automaton;

    protected Order(ListedInstrument instrument, int qty, String comment, IOrderAutomaton automaton, long ts) {
        this.qty = qty;
        this.instrument = instrument;
        this.internalId = OrderManager.getInstance().getNewOrderId();
        this.comment = comment;
        this.automaton = automaton;
        creationTimestamp = ts;
    }

    public void requestCancel() {
        this.cancelRequested = true;
    }

    public boolean isCancelRequested() {
        return cancelRequested;
    }

    public int getQty() {
        return qty;
    }

    public ListedInstrument getInstrument() {
        return instrument;
    }

    public long getCreationTimestamp() {
        return creationTimestamp;
    }

    public IOrderAutomaton getAutomaton() {
        return automaton;
    }

    public String getMarketId() {
        return marketId;
    }

    public void setMarketId(String marketId) {
        this.marketId = marketId;
    }

    public long getMatchingTimestamp() {
        return matchingTimestamp;
    }

    public void setMatchingTimestamp(long matchingTimestamp) {
        this.matchingTimestamp = matchingTimestamp;
    }
}
